package com.autumn.mybatis.provider;

/**
 * 自动获取驱动 ,仅作为自动获取转换
 * 
 * @author 杨昌国 2018-03-18 00:37:47
 */
public final class AutoProvider extends AbstractProvider {

	private String driveName;
	private int connectType;
	private IInsertBuilder insertBuilder;
	private IDeleteBuilder deleteBuilder;
	private IUpdateBuilder updateBuilder;
	private IQueryBuilder queryBuilder;
	private IDefinitionBuilder definitionBuilder;
	private ICommandBuilder commandBuilder;

	/**
	 * 
	 * @param dbProvider
	 */
	public void setDbProvider(IDbProvider dbProvider) {
		synchronized (this) {
			if (dbProvider == null || dbProvider.equals(this)) {
				return;
			}
			this.driveName = dbProvider.getDriveName();
			this.connectType = dbProvider.getConnectType();
			this.insertBuilder = dbProvider.getInsertBuilder();
			this.deleteBuilder = dbProvider.getDeleteBuilder();
			this.updateBuilder = dbProvider.getUpdateBuilder();
			this.queryBuilder = dbProvider.getQueryBuilder();
			this.definitionBuilder = dbProvider.getDefinitionBuilder();
			this.commandBuilder = dbProvider.getCommandBuilder();
		}
	}

	@Override
	public String getDriveName() {
		return this.driveName;
	}

	@Override
	public int getConnectType() {
		return this.connectType;
	}

	@Override
	public IInsertBuilder getInsertBuilder() {
		return this.insertBuilder;
	}

	@Override
	public IDeleteBuilder getDeleteBuilder() {
		return this.deleteBuilder;
	}

	@Override
	public IUpdateBuilder getUpdateBuilder() {
		return this.updateBuilder;
	}

	@Override
	public IQueryBuilder getQueryBuilder() {
		return this.queryBuilder;
	}

	@Override
	public IDefinitionBuilder getDefinitionBuilder() {
		return this.definitionBuilder;
	}

	@Override
	public ICommandBuilder getCommandBuilder() {
		return this.commandBuilder;
	}

}
